//
//  BaseViewController.swift
//  Photos
//
//  Created by zhangjianyun on 17/7/27.
//  Copyright © 2017年 com.taihejiacheng. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

    var pageMenu : CAPSPageMenu?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        var controllerArray : [UIViewController] = []
        
        self.navigationItem.title = "Photos"
        self.navigationController?.isNavigationBarHidden = false
        self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.navigationBarTitleTextColor()]
        self.navigationController?.navigationBar.barTintColor = UIColor.navigationBarBackgroundColor()
        self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        self.navigationController?.navigationBar.shadowImage = UIImage()
        self.navigationController?.navigationBar.isTranslucent = false
        
        
        let hot = HomeCollectionViewController(nibName: "HomeCollectionViewController", bundle: nil)
        hot.title = "Hot"
        hot.API_URL = Config.HOT_URL
        hot.loadShots()
        controllerArray.append(hot)
        
        let all = HomeCollectionViewController(nibName: "HomeCollectionViewController", bundle: nil)
        all.title = "All"
        all.API_URL = Config.SEARCH_URL
        all.loadShots()
        controllerArray.append(all)
//        
//        let teamsShot = HomeCollectionViewController(nibName: "HomeCollectionViewController", bundle: nil)
//        teamsShot.title = "Teams"
//        teamsShot.API_URL = Config.TEAMS_URL
//        teamsShot.loadShots()
//        controllerArray.append(teamsShot)
//        
//        let reboundsShot = HomeCollectionViewController(nibName: "HomeCollectionViewController", bundle: nil)
//        reboundsShot.title = "Rebounds"
//        reboundsShot.API_URL = Config.REBOUNDS_URL
//        reboundsShot.loadShots()
//        controllerArray.append(reboundsShot)
        
        let parameters: [CAPSPageMenuOption] = [
            .scrollMenuBackgroundColor(UIColor.scrollMenuBackgroundColor()),
            .viewBackgroundColor(UIColor.viewBackgroundColor()),
            .selectionIndicatorColor(UIColor.selectionIndicatorColor()),
            .bottomMenuHairlineColor(UIColor.bottomMenuHairlineColor()),
            .selectedMenuItemLabelColor(UIColor.selectedMenuItemLabelColor()),
            .unselectedMenuItemLabelColor(UIColor.unselectedMenuItemLabelColor()),
            .selectionIndicatorHeight(2.0),
            .menuItemFont(UIFont(name: "HiraKakuProN-W6", size: 13.0)!),
            .menuHeight(40.0),
            .menuItemWidth(UIScreen.main.bounds.width/2.0),
            .menuMargin(0.0),
            //            "useMenuLikeSegmentedControl": true,
            .menuItemSeparatorRoundEdges(true),
            //            "enableHorizontalBounce": true,
            //            "scrollAnimationDurationOnMenuItemTap": 300,
            .centerMenuItems(true)]
        
        pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRect(x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.height), pageMenuOptions: parameters)
        
        self.view.addSubview(pageMenu!.view)
        self.addChildViewController(pageMenu!)
        pageMenu?.didMove(toParentViewController: self)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}
